<template>
    <div v-if="searchState">
      <el-form size="small" :inline="true" class="query-form" ref="searchForm" :model="searchForm" @keyup.enter.native="refreshList()" @submit.native.prevent>
            <!-- 搜索框-->
            <el-form-item label="姓名" prop="name">
                   <el-input size="small" v-model="searchForm.name" placeholder="姓名" clearable></el-input>
            </el-form-item>
            <el-form-item label="单位" prop="oneInstitutional">
               <el-select v-model="searchForm.oneInstitutional" filterable multiple placeholder="请填写单位" style="width:100%;" >
                 <el-option v-for="item in oneInstitutionalArr" @click.native="searchTwoInstitutionalName(item)" :label="item.organization" :value="item.organization" :key="item.id"></el-option>
               </el-select>
            </el-form-item>
            <el-form-item label="现任职务(校内)" prop="currentPosition">
               <el-input size="small" v-model="searchForm.currentPosition" placeholder="现任职务(校内)" clearable></el-input>
            </el-form-item>
            <el-form-item label="现任职务(文件)" prop="currentPositionFile">
               <el-input size="small" v-model="searchForm.currentPositionFile" placeholder="现任职务(文件)" clearable></el-input>
            </el-form-item>
            <el-form-item label="行政级别" prop="administrativeLevel">
               <!-- <el-input size="small" v-model="searchForm.administrativeLevel" placeholder="行政级别" clearable></el-input> -->
               <el-select v-model="searchForm.administrativeLevel" placeholder="行政级别" filterable multiple  style="width:100%;" >
                 <el-option v-for="item in administrativeLevelArr" :label="item.administrativeLevel" :value="item.administrativeLevel" :key="item.id"></el-option>
               </el-select>
            </el-form-item>
            <span v-if="showSearch">
            <el-form-item label="科室名称" prop="twoInstitutionalName">
                <el-select v-model="searchForm.twoInstitutionalName" filterable multiple placeholder="请填写科室名称" style="width:100%;" >
                  <el-option v-for="item in twoInstitutionalNameArr" :label="item.organization" :value="item.organization" :key="item.organization"></el-option>
                </el-select>
             </el-form-item>
          <el-form-item label="正处级领导职数" prop="zhengLeaderNumber">
              <el-input size="small" v-model="searchForm.zhengLeaderNumber" placeholder="正处级领导职数" clearable></el-input>
          </el-form-item>
          <el-form-item label="副处级领导职数" prop="fuLeaderNumber">
              <template>
                <el-input size="small" v-model="searchForm.fuLeaderNumber" placeholder="正处级领导职数" clearable></el-input>
              </template>
          </el-form-item>
            <el-form-item label="岗位现状(正处)" prop="oneJobStatus">
               <el-input size="small" v-model="searchForm.oneJobStatus" placeholder="请填写岗位现状(正处)" clearable></el-input>
            </el-form-item>
            <el-form-item label="岗位现状(副处)" prop="heightEducation">
               <el-input size="small" v-model="searchForm.heightEducation" placeholder="请填写岗位现状(副处)" clearable></el-input>
            </el-form-item>
            <el-form-item label="科级领导职数" prop="keLeaderNumber">
                <el-input size="small" v-model="searchForm.keLeaderNumber" placeholder="科级领导职数" clearable></el-input>
            </el-form-item>
            <el-form-item label="岗位现状(正科)" prop="twoJobStatus">
               <el-input size="small" v-model="searchForm.twoJobStatus" placeholder="请填写岗位现状(正科)" clearable></el-input>
            </el-form-item>
            <el-form-item label="岗位现状(副科)" prop="oneEducation">
               <el-input size="small" v-model="searchForm.oneEducation" placeholder="请填写岗位现状(副科)" clearable></el-input>
            </el-form-item>
            <el-form-item label="性别" prop="gender">
               <!-- <el-input size="small" v-model="searchForm.gender" placeholder="性别" clearable></el-input> -->
               <el-select v-model="searchForm.gender" placeholder="请填写性别" style="width:100%;" >
                 <el-option v-for="item in $dictUtils.getDictList('gender')" :label="item.label" :value="item.value" :key="item.value"></el-option>
               </el-select>
            </el-form-item>
            <el-form-item label="民族" prop="national">
               <el-input size="small" v-model="searchForm.national" placeholder="民族" clearable></el-input>
            </el-form-item>
            <el-form-item label="出生年月" prop="born">
               <!-- <el-input size="small" v-model="searchForm.born" placeholder="出生年月" clearable></el-input> -->
               <el-date-picker
                     value-format="yyyy.MM"
                     v-model="searchForm.born"
                     type="month"
                     placeholder="选择日期">
                   </el-date-picker>
            </el-form-item>
            <el-form-item label="年龄" prop="age">
               <el-input size="small" v-model="searchForm.age" placeholder="年龄" clearable></el-input>
            </el-form-item>
            <el-form-item label="任现职时间" prop="inOffice">
               <!-- <el-input size="small" v-model="searchForm.inOffice" placeholder="任职时间" clearable></el-input> -->
               <el-date-picker
                     value-format="yyyy.MM"
                     v-model="searchForm.inOffice"
                     type="month"
                     placeholder="选择日期">
                   </el-date-picker>
            </el-form-item>
            <el-form-item label="任职时长" prop="inOfficeTime">
               <el-input size="small" v-model="searchForm.inOfficeTime" placeholder="任职时长" clearable></el-input>
            </el-form-item>
            <el-form-item label="任同级时间" prop="asClass">
               <!-- <el-input size="small" v-model="searchForm.asClass" placeholder="任级时间" clearable></el-input> -->
               <el-date-picker
                     value-format="yyyy.MM"
                     v-model="searchForm.asClass"
                     type="month"
                     placeholder="选择日期">
                   </el-date-picker>
            </el-form-item>
            <el-form-item label="任级时长" prop="asClassTime">
               <el-input size="small" v-model="searchForm.asClassTime" placeholder="任级时长" clearable></el-input>
            </el-form-item>
            <el-form-item label="全日制教育学历学位" prop="degree">
               <el-input size="small" v-model="searchForm.degree" placeholder="全日制教育学历学位" clearable></el-input>
            </el-form-item>
            <el-form-item label="全日制教育毕业院校及专业" prop="professional">
               <el-input size="small" v-model="searchForm.professional" placeholder="全日制教育毕业院校及专业" clearable></el-input>
            </el-form-item>
            <el-form-item label="在职教育学历学位" prop="nowDegree">
               <el-input size="small" v-model="searchForm.nowDegree" placeholder="在职教育学历学位" clearable></el-input>
            </el-form-item>
            <el-form-item label="在职教育毕业专业" prop="nowProfessional">
               <el-input size="small" v-model="searchForm.nowProfessional" placeholder="在职教育毕业专业" clearable></el-input>
            </el-form-item>
            <el-form-item label="最高学历/学位" prop="heightRecord">
               <el-input size="small" v-model="searchForm.heightRecord" placeholder="最高学历/学位" clearable></el-input>
            </el-form-item>
            <el-form-item label="专业技术职务" prop="technicalPosition">
               <el-input size="small" v-model="searchForm.technicalPosition" placeholder="专业技术职务" clearable></el-input>
            </el-form-item>
            <el-form-item label="专业技术资格级别" prop="technicalLevel">
               <el-select v-model="searchForm.technicalLevel" placeholder="请填写专业技术资格级别" style="width:100%;" >
                 <el-option v-for="item in technicalLevelArr" :label="item.label" :value="item.value" :key="item.value"></el-option>
               </el-select>
               </el-select>
            </el-form-item>
            <el-form-item label="参工时间" prop="workforceDate">
               <!-- <el-input size="small" v-model="searchForm.workforceDate" placeholder="参工时间" clearable></el-input> -->
               <el-date-picker
                     value-format="yyyy.MM"
                     v-model="searchForm.workforceDate"
                     type="month"
                     placeholder="选择日期">
                   </el-date-picker>
            </el-form-item>
            <el-form-item label="工龄" prop="workYears">
               <el-input size="small" v-model="searchForm.workYears" placeholder="工龄" clearable></el-input>
            </el-form-item>
            <el-form-item label="入党时间" prop="inPartyDate">
               <el-date-picker
                     value-format="yyyy.MM"
                     v-model="searchForm.inPartyDate"
                     type="month"
                     placeholder="选择日期">
                   </el-date-picker>
            </el-form-item>
            <el-form-item label="党龄" prop="heightProfessionalDate">
               <el-input size="small" v-model="searchForm.heightProfessionalDate" placeholder="党龄" clearable></el-input>
            </el-form-item>
            <!-- <el-form-item label="最高毕业院校及所学专业" prop="heightGraduationSchool">
               <el-input size="small" v-model="searchForm.heightGraduationSchool" placeholder="最高毕业院校及所学专业" clearable></el-input>
            </el-form-item>
            <el-form-item label="第一学历学位原毕业时间" prop="oneProfessionalDate">
               <el-date-picker
                     value-format="yyyy-MM-dd"
                     v-model="searchForm.oneProfessionalDate"
                     type="date"
                     placeholder="选择日期">
                   </el-date-picker>
            </el-form-item>
            <el-form-item label="第一学历学位原毕业院校及所学专业" prop="oneGraduationSchool">
               <el-input size="small" v-model="searchForm.oneGraduationSchool" placeholder="第一学历学位原毕业院校及所学专业" clearable></el-input>
            </el-form-item>
            <el-form-item label="考核年份" prop="assessYear">
               <el-input size="small" v-model="searchForm.assessYear" placeholder="考核年份" clearable></el-input>
            </el-form-item> -->
            <el-form-item label="年" prop="createdate">
              <el-input-number v-model="searchForm.createdate" controls-position="right" :min="2021" :max="4000"></el-input-number>
            </el-form-item>
            <!-- <el-form-item label="考核年份" prop="assessYear">
               <el-date-picker
                     value-format="yyyy-MM-dd"
                     v-model="searchForm.assessYear"
                     type="date"
                     placeholder="选择日期">
                   </el-date-picker>
            </el-form-item> -->
            <el-form-item label="备注信息" prop="remarks">
               <el-input size="small" v-model="searchForm.remarks" placeholder="备注信息" clearable></el-input>
            </el-form-item>
            <el-form-item label="员工编号" prop="workNumber">
               <el-input size="small" v-model="searchForm.workNumber" placeholder="员工编号" clearable></el-input>
            </el-form-item>
            <!-- <el-form-item label="职务" prop="currentPosition">
                   <el-input size="small" v-model="searchForm.currentPosition" placeholder="职务" clearable></el-input>
            </el-form-item> -->
            <el-form-item label="岗位性质" prop="jobNature">
                   <!-- <el-input size="small" v-model="searchForm.jobNature" placeholder="单位" clearable></el-input> -->
                   <el-select v-model="searchForm.jobNature" filterable multiple placeholder="请填写岗位性质" style="width:100%;" >
                     <el-option v-for="item in jobNatureArr" :label="item" :value="item" :key="item"></el-option>
                   </el-select>
            </el-form-item>
            <el-form-item label="岗位分类" prop="identity">
               <!-- <el-input size="small" v-model="searchForm.identity" placeholder="身份" clearable></el-input> -->
               <el-select v-model="searchForm.identity" filterable multiple placeholder="请填写岗位分类" style="width:100%;" >
                 <el-option v-for="item in identityArr" :label="item.identity" :value="item.identity" :key="item.id"></el-option>
               </el-select>
            </el-form-item>
          </span>
          <el-form-item>
            <el-button type="primary" @click="refreshList()" size="small">查询</el-button>
            <el-button @click="resetSearch()" size="small">重置</el-button>
            <el-button type="primary" @click="showSearch = !showSearch" size="small">更多</el-button>
          </el-form-item>
      </el-form>
        <!-- 导入导出-->
      <el-dialog  title="导入Excel" :visible.sync="isImportCollapse">
          <el-form size="small" :inline="true" v-show="isImportCollapse"  ref="importForm">
             <el-form-item>
              <el-button type="default" @click="downloadTpl()" size="small">下载模板</el-button>
             </el-form-item>
             <el-form-item prop="loginName">
                <el-upload
                  class="upload-demo"
                  :action="`${this.$http.BASE_URL}/peopleinformation/basicdata/peopleInformation/import`"
                  :on-success="uploadSuccess"
                   :show-file-list="true">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">只允许导入“xls”或“xlsx”格式文件！</div>
                </el-upload>
            </el-form-item>
          </el-form>
      </el-dialog>
      <div class="bg-white top">
      <el-row>
        <el-button v-if="hasPermission('peopleinformation:basicdata:peopleInformation:add')" type="primary" size="small" icon="el-icon-plus" @click="add()">新建</el-button>
        <!-- <el-button v-if="hasPermission('peopleinformation:basicdata:peopleInformation:add')" type="primary" size="small" icon="el-icon-plus" @click="ceshi()">加80条数据</el-button> -->
        <el-button type="warning" size="small" icon="el-icon-edit-outline" @click="assess('now')" :disabled="dataListSelections.length <= 0" plain>本次考核人员导出</el-button>
        <el-button type="warning" size="small" icon="el-icon-edit-outline" @click="assess('add')" :disabled="dataListSelections.length <= 0" plain>新增考核人员导出</el-button>
        <!-- <el-button v-if="hasPermission('peopleinformation:basicdata:peopleInformation:edit')" type="warning" size="small" icon="el-icon-edit-outline" @click="edit()"
         :disabled="dataListSelections.length != 1" plain>修改</el-button> -->
         <!-- <el-button type="warning"   size="small" icon="el-icon-edit-outline" @click="importPresentData()" plain>快捷导入本年人员信息</el-button>
             <el-date-picker
               v-if="isPresentData"
               size="small"
               value-format="yyyy"
               v-model="importYear"
               type="year"
               placeholder="选择年">
             </el-date-picker> -->
             <el-button type="primary" v-if="isPresentData" @click="importPeople()" size="small">导入</el-button>
        <el-button v-if="hasPermission('peopleinformation:basicdata:peopleInformation:del')" type="danger"   size="small" icon="el-icon-delete" @click="del()"
                  :disabled="dataListSelections.length <= 0" plain>删除
        </el-button>
        <el-button-group class="pull-right">
            <el-button v-if="hasPermission('peopleinformation:basicdata:peopleInformation:import')" type="default" size="small" icon="el-icon-upload2" title="导入" @click="isImportCollapse = !isImportCollapse"></el-button>
            <el-button v-if="hasPermission('peopleinformation:basicdata:peopleInformation:export')" type="default" size="small" icon="el-icon-download" title="导出" @click="exportExcel()"></el-button>
            <el-button
              type="default"
              size="small"
              icon="el-icon-refresh"
              @click="refreshList">
            </el-button>
        </el-button-group>
      </el-row>
    <el-table
      :data="dataList"
      ref="report-table"
      size="small"
      @selection-change="selectionChangeHandle"
      @sort-change="sortChangeHandle"
      v-loading="loading"
      class="table">
      <span v-if="tests">
      <el-table-column
        type="selection"
        fixed="left"
        header-align="center"
        align="center"
        width="50">
      </el-table-column>
      </span>
      <el-table-column
      label="序号"
      type="index">
      </el-table-column>
      <el-table-column
          prop="oneInstitutional"
          show-overflow-tooltip
          min-width="200px"
          label="单位">
        </el-table-column>
      <!-- <el-table-column
          prop="zhengLeaderNumber"
          show-overflow-tooltip
          label="正处级领导职数">
        </el-table-column>
      <el-table-column
          prop="fuLeaderNumber"
          show-overflow-tooltip
          label="副处级领导职数">
        </el-table-column>
      <el-table-column
          prop="oneJobStatus"
          show-overflow-tooltip
          min-width="150px"
          label="岗位现状(正处)">
        </el-table-column>
        <el-table-column
            prop="heightEducation"
            show-overflow-tooltip
            min-width="150px"
            label="岗位现状(副处)">
          </el-table-column>
      <el-table-column
          prop="twoInstitutionalName"
          show-overflow-tooltip
          min-width="200px"
          label="科室名称">
        </el-table-column>
      <el-table-column
          prop="keLeaderNumber"
          show-overflow-tooltip
          label="科级领导职数">
        </el-table-column>
      <el-table-column
          prop="twoJobStatus"
          show-overflow-tooltip
          min-width="150px"
          label="岗位现状(正科)">
        </el-table-column>
        <el-table-column
            prop="oneEducation"
            show-overflow-tooltip
            fit='true'
            min-width="150px"
            label="岗位现状(副科)">
          </el-table-column> -->
      <el-table-column
        prop="name"
        show-overflow-tooltip
        label="姓名">
      </el-table-column>
      <!-- <el-table-column
          prop="gender"
          show-overflow-tooltip
          label="性别">
        </el-table-column>
        <el-table-column
            prop="national"
            show-overflow-tooltip
            label="民族">
          </el-table-column>
        <el-table-column
            prop="born"
            show-overflow-tooltip
            label="出生年月">
            <template slot-scope="scope">
              {{scope.row.born.split('.')[0] + '.' + scope.row.born.split('.')[1]}}
            </template>
          </el-table-column>
        <el-table-column
            prop="age"
            show-overflow-tooltip
            label="年龄">
          </el-table-column>
        <el-table-column
            prop="currentPositionFile"
            show-overflow-tooltip
            min-width="150px"
            label="现任职务(文件)">
          </el-table-column> -->
    <el-table-column
        prop="currentPosition"
        show-overflow-tooltip
        min-width="150px"
        label="现任职务(校内)">
      </el-table-column>
        <!-- <el-table-column
            prop="inOffice"
            show-overflow-tooltip
            label="任现职时间">
            <template slot-scope="scope">
              {{scope.row.inOffice.split('.')[0] + '.' + scope.row.inOffice.split('.')[1]}}
            </template>
          </el-table-column>
        <el-table-column
            prop="inOfficeTime"
            show-overflow-tooltip
            label="任职时长">
          </el-table-column> -->
        <el-table-column
            prop="administrativeLevel"
            show-overflow-tooltip
            label="行政级别">
          </el-table-column>
        <!-- <el-table-column
            prop="asClass"
            show-overflow-tooltip
            label="任同级时间">
            <template slot-scope="scope">
              {{scope.row.asClass.split('.')[0] + '.' + scope.row.asClass.split('.')[1]}}
            </template>
          </el-table-column>
        <el-table-column
            prop="asClassTime"
            show-overflow-tooltip
            label="任级时长">
          </el-table-column>
          <el-table-column label="全日制教育" align="center">
          <el-table-column
              prop="degree"
              show-overflow-tooltip
              min-width="200px"
              label="学历学位">
            </el-table-column>
          <el-table-column
              prop="professional"
              show-overflow-tooltip
              min-width="200px"
              label="毕业院校及专业">
            </el-table-column>
            </el-table-column>
        <el-table-column label="在职教育" align="center">
          <el-table-column
              prop="nowDegree"
              show-overflow-tooltip
              min-width="200px"
              label="学历学位">
            </el-table-column>
          <el-table-column
              prop="nowProfessional"
              show-overflow-tooltip
              min-width="200px"
              label="毕业专业">
            </el-table-column>
        </el-table-column>
        <el-table-column
            prop="technicalPosition"
            show-overflow-tooltip
            min-width="200px"
            label="专业技术职务">
           </el-table-column>
        <el-table-column
            prop="technicalLevel"
            show-overflow-tooltip
            label="专业技术资格级别">
          </el-table-column>
          <el-table-column
              prop="workforceDate"
              show-overflow-tooltip
              label="参工时间">
              <template slot-scope="scope">
                {{scope.row.workforceDate.split('.')[0] + '.' + scope.row.workforceDate.split('.')[1]}}
              </template>
            </el-table-column> -->
          <!-- <el-table-column
              prop="workYears"
              show-overflow-tooltip
              label="工龄">
            </el-table-column>
          <el-table-column
              prop="inPartyDate"
              show-overflow-tooltip
              label="入党时间">
              <template slot-scope="scope">
                {{scope.row.inPartyDate.split('.')[0] + '.' + scope.row.inPartyDate.split('.')[1]}}
              </template>
            </el-table-column>
          <el-table-column
              prop="heightProfessionalDate"
              show-overflow-tooltip
              label="党龄">
            </el-table-column> -->
          <!-- <el-table-column
              prop="heightGraduationSchool"
              show-overflow-tooltip
              sortable="custom"
              label="毕业院校及所学专业">
            </el-table-column>
          <el-table-column
              prop="oneProfessionalDate"
              show-overflow-tooltip
              sortable="custom"
              label="原毕业时间">
            </el-table-column>
          <el-table-column
              prop="oneGraduationSchool"
              show-overflow-tooltip
              sortable="custom"
              label="原毕业院校及所学专业">
            </el-table-column> --> -->
          <!-- <el-table-column
              prop="assessYear"
              show-overflow-tooltip
              sortable="custom"
              label="考核年份">
            </el-table-column>
      <!-- 暂时注释掉 新建表单时多加一个字段以防后期需求添加使用 -->
    <!-- <el-table-column
        prop="heightRecord"
        show-overflow-tooltip
        min-width="200px"
        label="最高学历/学位">
      </el-table-column>
    <el-table-column
        prop="workNumber"
        show-overflow-tooltip
        label="员工编号">
      </el-table-column>
      <el-table-column
          prop="jobNature"
          show-overflow-tooltip
          label="岗位性质">
        </el-table-column> -->
       <el-table-column
         prop="identity"
         min-width="150px"
         show-overflow-tooltip
         label="岗位分类">
       </el-table-column>
        <!-- <el-table-column
            prop="photo"
            show-overflow-tooltip
            label="照片">
            <template slot-scope="scope" v-if="scope.row.photo">
              <el-image
                style="height: 50px;width:50px;margin-right:10px;"
                :src="src" v-for="(src, index) in scope.row.photo.split('|')" :key="index"
                :preview-src-list="scope.row.photo.split('|')">
              </el-image>
            </template>
          </el-table-column> -->
    <el-table-column
        prop="remarks"
        show-overflow-tooltip
        label="备注信息">
      </el-table-column>
      <!-- 用于测试 -->
      <!-- <el-table-column
          prop="remarks"
          align="center"
          width="1000px"
          label="分数">
          <template slot-scope="scope" >
            <el-radio-group v-model="scope.row.remarks" size="mini">
                  <el-radio-button label="一般"></el-radio-button>
                  <el-radio-button label="良好"></el-radio-button>
                  <el-radio-button label="优秀"></el-radio-button>
            </el-radio-group>
          </template>
        </el-table-column> -->
      <span v-if="tests">
      <el-table-column
        header-align="center"
        align="center"
        fixed="right"
        :key="Math.random()"
        width="200"
        label="操作">
        <template  slot-scope="scope">
          <el-button v-if="hasPermission('peopleinformation:basicdata:peopleInformation:view')" type="text" icon="el-icon-view" size="small" @click="view(scope.row.id)">查看</el-button>
          <el-button v-if="hasPermission('peopleinformation:basicdata:peopleInformation:edit')" type="text" icon="el-icon-edit" size="small" @click="edit(scope.row.id)">修改</el-button>
          <el-button v-if="hasPermission('peopleinformation:basicdata:peopleInformation:del')" type="text"  icon="el-icon-delete" size="small" @click="del(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
      </span>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageNo"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="total"
      background
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    </div>
        <!-- 弹窗, 新增 / 修改 -->
    <PeopleInformationForm  ref="peopleInformationForm" @refreshDataList="refreshList"></PeopleInformationForm>
    <asyn-for-tool ref='asynForTool' @returnData='returnData(arguments)'></asyn-for-tool>
    <filter-data ref='filterData' @returnFilterData='returnFilterData(arguments)'></filter-data>
  </div>
</template>

<script>
  import PeopleInformationForm from './PeopleInformationForm'
  export default {
    data () {
      return {
        searchForm: {
          oneInstitutional: '', // 一级机构名称
          zhengLeaderNumber: '', // 正处级领导职数
          fuLeaderNumber: '', // 副处级领导职数
          oneJobStatus: '', // 一级岗位现状
          twoInstitutionalName: '', // 二级机构名称
          keLeaderNumber: '', // 科级领导职数
          twoJobStatus: '', // 二级岗位现状
          name: '', // 姓名
          gender: '', // 性别
          national: '', // 民族
          born: '', // 出生年月
          age: '', // 年龄
          currentPositionFile: '', // 现任职务(文件)
          currentPosition: '', // 现任职务(校内)
          identity: '', // 身份
          photo: '', //照片
          createdate: new Date().getFullYear(),
          inOffice: '', // 任现职时间
          inOfficeTime: '', // 任职时长
          administrativeLevel: '', // 行政级别
          asClass: '', // 任同级时间
          asClassTime: '', // 任级时长
          degree: '', // 学历学位
          professional: '', //毕业院校及专业
          nowDegree: '', // 现在学历学位
          nowProfessional: '', // 现在毕业专业
          heightRecord: '', // 最高学历/学位
          technicalPosition: '', // 专业技术职务
          technicalLevel: '', // 专业技术资格级别
          workforceDate: '', // 参工时间
          workYears: '', // 工龄
          inPartyDate: '', // 入党时间
          heightEducation: '', // 现文化程度
          heightProfessionalDate: '', // 最高毕业时间
          heightGraduationSchool: '', // 最高毕业院校及所学专业
          oneEducation: '', // 第一文化程度
          oneProfessionalDate: '', // 第一毕业时间
          oneGraduationSchool: '', // 第一毕业院校及所学专业
          assessYear: '', // 考核年份
          remarks: '', // 备注信息
          workNumber: '', // 员工编号
          jobNature: ''  // 岗位性质
        },
        showSearch: false,
        ceshiList: [],
        isPresentData: false,
        importYear: '',
        dataListSelectionDealSearch: [], // 用于数据查询
        dataListSelectionDeal: [], // 用于多数据处理
        dataListSelectionDealAgain: [], // 用于多数据再次处理
        dataList: [],
        pageNo: 1,
        pageSize: 10,
        total: 0,
        orderBy: '',
        dataListSelections: [], // 多选数据
        isImportCollapse: false,
        loading: false,
        filterData: [], // dataList数据过滤处理用于导出
        headData: '', // 加入表头的数据处理 此时已经是个完整数据
        merge: '', // 单元格合并
        headFilterData: [], // 过滤的表头数据
        headFilterIndex: '', // 表头过滤下标，
        administrativeLevelArr: [], // 行政级别 搜索框
        identityArr: [], // 身份 搜索框
        unitArr: [], // 单位 搜索框
        administrativeLevel: '',
        unit: '',
        identity: '',
        tests: true,
        state: false,
        num: 1,
        finishNumber: 0,
        submitNumber: 0,
        oneInstitutionalArr: [],
        twoInstitutionalNameArr: [],
        jobNatureArr: [],
        loadings: '',
        time: '',
        timeState: '',
        technicalLevelArr: [{
          value: '正高级',
          label: '正高级'
        }, {
          value: '副高级',
          label: '副高级'
        }, {
          value: '中级',
          label: '中级'
        }, {
          value: '助理级',
          label: '助理级'
        }, {
          value: '无',
          label: '无'
        }]
      }
    },
    components: {
      PeopleInformationForm
    },
    watch: {
      createdate (newVal, oldVal) {
        if (this.createdate === '' || this.createdate === null || this.createdate === undefined || this.ticketCount === undefined || this.ticketCount === undefined || this.ticketCount === undefined) {
          this.searchForm.ticketCount = new Date().getFullYear() + '-' + 1
        } else {
          this.searchForm.ticketCount = this.createdate + '-' + this.ticketCount
        }
      },
      ticketCount (newVal, oldVal) {
        if (this.createdate === '' || this.createdate === null || this.createdate === undefined || this.ticketCount === undefined || this.ticketCount === undefined || this.ticketCount === undefined) {
          this.searchForm.ticketCount = new Date().getFullYear() + '-' + 1
        } else {
          this.searchForm.ticketCount = this.createdate + '-' + this.ticketCount
        }
      }
    },
    activated () {
      if (localStorage.getItem('loginName') === 'admin') {
        this.refreshList()
      }
    },
    computed: {
      searchState () {
        return localStorage.getItem('loginName') === 'admin'
      }
    },
    methods: {
      // 总下拉请求集合调用
      searchList () {
        this.$axios.all([this.searchAdministrative(), this.searchIdentity(), this.searchUnit(), this.searchOneInstitutional()])
      },
      // 搜索框下拉数据提供 单位名称下拉框数据请求
      searchOneInstitutional () {
        this.$http({
          url: '/peopleinformation/organization/nameOfOrganization/treeData',
          method: 'get'
        }).then(({data}) => {
          this.oneInstitutionalArr = []
          for (let index = 0; index < data.treeData.length; index++) {
            this.oneInstitutionalArr.push(data.treeData[index])
          }
        })
      },
      // 搜索框下拉数据提供 二级机构名称下拉框数据请求
      searchTwoInstitutionalName (twoArr) {
        this.twoInstitutionalNameArr = []
        for (let index = 0; index < twoArr.children.length; index++) {
           this.twoInstitutionalNameArr.push(twoArr.children[index])
        }
      },
      // 搜索框下拉数据提供 行政级别下拉框数据请求
      searchAdministrative () {
        this.$http({
          url: '/peopleinformation/administrativelevel/peopleAdministrativeLevel/list',
          method: 'get',
          params: {
            administrativeLevel: ''
          }
        }).then(({data}) => {
          this.administrativeLevelArr = data.page.list
        })
      },
      // 搜索框下拉数据提供 岗位类别下拉框数据请求
      searchIdentity () {
        this.$http({
          url: '/peopleinformation/identityiformation/peopleIdentityInformation/list',
          method: 'get',
          params: {
            identity: ''
          }
        }).then(({data}) => {
          this.identityArr = data.page.list
        })
      },
      // 搜索框下拉数据提供 岗位性质下拉框数据请求
      searchjobNature () {
        this.$http({
          url: '/peopleinformation/peoplejobnature/peopleJobNature/list',
          method: 'get',
          params: {
            jobNature: ''
          }
        }).then(({data}) => {
          this.jobNatureArr = []
          for (var i in data.page.list) {
            this.jobNatureArr.push(data.page.list[i].jobNature)
          }
        })
      },
      // filter-data过滤表头导出数据
      returnFilterData (value) {
        // 表头过滤下标
        this.headFilterIndex = []
      // 导出Eexcel
      this.$exportXLXS.exportDataXlsx(this.$refs['report-table'].$el, '人员信息')
      },
      // asyn-for-tool组件返回的数据
      returnData (value) {
        this.finishNumber++
        if (this.state === 'list') {
          if (value[0].page.list.length === 0) {
            this.dataListSelectionDealAgain.push(this.dataListSelectionDeal[value[2]])
            if (this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1].special === '' || this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1].special === undefined) {
              if (this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1].organizationLevel === '机关') {
                this.$set(this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1], 'ticket', '所有中层干部(校领导票),机关中层干部(同级票),机关中层干部(服务对象票),中层干部(群众票)')
              } else if (this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1].organizationLevel === '教学') {
                this.$set(this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1], 'ticket', '所有中层干部(校领导票),教学教辅中层干部(同级票),中层干部(群众票)')
              } else if (this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1].organizationLevel === '教辅') {
                this.$set(this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1], 'ticket', '所有中层干部(校领导票),教学教辅中层干部(同级票),教辅中层干部(服务对象票),中层干部(群众票)')
              }
            } else {
              if (this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1].special === '机关') {
                this.$set(this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1], 'ticket', '所有中层干部(校领导票),机关中层干部(同级票),机关中层干部(服务对象票),中层干部(群众票)')
              } else if (this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1].special === '教学') {
                this.$set(this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1], 'ticket', '所有中层干部(校领导票),教学教辅中层干部(同级票),中层干部(群众票)')
              } else if (this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1].special === '教辅') {
                this.$set(this.dataListSelectionDealAgain[this.dataListSelectionDealAgain.length - 1], 'ticket', '所有中层干部(校领导票),教学教辅中层干部(同级票),教辅中层干部(服务对象票),中层干部(群众票)')
              }
            }
          }
         if (this.finishNumber === this.submitNumber) {
           this.importBasicData()
         }
        } else if (this.state === 'save') {
          if (this.finishNumber === this.submitNumber) {
            this.bindDataRepeat(this.dataListSelectionDealAgain)
          }
        }
      },
      // 导入基础数据
      importBasicData () {
        // 做不重复添加数据处理
        this.$confirm(`您导入数据数量为${this.dataListSelectionDeal.length},实际可导入数据数量为${this.dataListSelectionDealAgain.length}点击确认后开始导入，如有问题请核对是否重复或者等待时间过短点击取消即可!`, '统计完成', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            showClose: false,
            type: 'warning'
          }).then(() => {
            if (this.dataListSelectionDealAgain.length !== 0) {
              this.finishNumber = 0
              this.submitNumber = this.dataListSelectionDealAgain.length
              this.importAssess('保存中，请勿刷新网页')
              this.state = 'save'
              if (this.timeState === 'add') {
                this.$http({
                  url: `/peopleinformation/checktime/checkTime/save`,
                  method: 'post',
                  data: {
                    time: this.time,
                    remarks: '人员'
                  }
                })
              }
              // 调用异步循环组件的循环请求方法
              this.$refs.asynForTool.func('/peopleinformation/peopleassessdata/peopleAssessInformation/save', 'post', this.dataListSelectionDealAgain, true)
            } else {
              this.loadings.close()
              this.refreshList()
            }
          }).catch(() => {
            this.loadings.close()
            this.refreshList()
            this.$message({
              type: 'info',
              message: '导入取消'
            })
          })
      },
      // 绑定数据查重
      bindDataRepeat (data) {
        var xiaolingdaoArr = []
        var xuefutongjiArr = []
        var jiguantongjiArr = []
        var jiaofufuwuArr = []
        var jiguanfuwuArr = []
        var qunzhongArr = []
        for (let i in data) {
          this.$set(data[i], 'mark', data[i].userId)
          this.$set(data[i], 'ticketCount', this.time)
          if (data[i].special === '' || data[i].special === undefined) {
            if (data[i].organizationLevel === '机关') {
              xiaolingdaoArr.push(data[i])
              jiguantongjiArr.push(data[i])
              jiguanfuwuArr.push(data[i])
              qunzhongArr.push(data[i])
            } else if (data[i].organizationLevel === '教学') {
              xiaolingdaoArr.push(data[i])
              xuefutongjiArr.push(data[i])
              qunzhongArr.push(data[i])
            } else if (data[i].organizationLevel === '教辅') {
              xiaolingdaoArr.push(data[i])
              xuefutongjiArr.push(data[i])
              jiaofufuwuArr.push(data[i])
              qunzhongArr.push(data[i])
            }
          } else {
            if (data[i].special === '机关') {
              xiaolingdaoArr.push(data[i])
              jiguantongjiArr.push(data[i])
              jiguanfuwuArr.push(data[i])
              qunzhongArr.push(data[i])
            } else if (data[i].special === '教学') {
              xiaolingdaoArr.push(data[i])
              xuefutongjiArr.push(data[i])
              qunzhongArr.push(data[i])
            } else if (data[i].special === '教辅') {
              xiaolingdaoArr.push(data[i])
              xuefutongjiArr.push(data[i])
              jiaofufuwuArr.push(data[i])
              qunzhongArr.push(data[i])
            }
          }
          if (Number(i) === data.length - 1) {
            this.$refs.asynForTool.func('/ticket/schleamiddlecadres/schoolleaderMiddlecadres/save', 'post', xiaolingdaoArr)
            this.$refs.asynForTool.func('/ticket/samelevelteach/samelevelTeach/save', 'post', xuefutongjiArr)
            this.$refs.asynForTool.func('/ticket/samelevelorgan/samelevelOrgan/save', 'post', jiguantongjiArr)
            this.$refs.asynForTool.func('/ticket/serviceteach/serviceTeach/save', 'post', jiaofufuwuArr)
            this.$refs.asynForTool.func('/ticket/serviceorgan/serviceOrgan/save', 'post', jiguanfuwuArr)
            this.$refs.asynForTool.func('/ticket/crowdmiddleleader/crowdMiddleleader/save', 'post', qunzhongArr)
            this.loadings.close()
          }
        }
      },
      // 获取数据列表
      refreshList () {
        this.loading = true
        if (this.searchForm.oneInstitutional !== '') {
          this.searchForm.oneInstitutional = this.searchForm.oneInstitutional.join(',')
        }
        if (this.searchForm.administrativeLevel !== '') {
          this.searchForm.administrativeLevel = this.searchForm.administrativeLevel.join(',')
        }
        if (this.searchForm.twoInstitutionalName !== '') {
          this.searchForm.twoInstitutionalName = this.searchForm.twoInstitutionalName.join(',')
        }
        if (this.searchForm.jobNature !== '') {
          this.searchForm.jobNature = this.searchForm.jobNature.join(',')
        }
        if (this.searchForm.identity !== '') {
          this.searchForm.identity = this.searchForm.identity.join(',')
        }
        this.$http({
          url: '/peopleinformation/basicdata/peopleInformation/list',
          method: 'get',
          params: {
            'pageNo': this.pageNo,
            'pageSize': this.pageSize,
            'orderBy': this.orderBy,
            ...this.searchForm
          }
        }).then(({data}) => {
          if (data && data.success) {
            this.dataList = data.page.list
            this.total = data.page.count
            this.loading = false
            if (this.searchForm.oneInstitutional !== '') {
              this.searchForm.oneInstitutional = this.searchForm.oneInstitutional.split(',')
            }
            if (this.searchForm.administrativeLevel !== '') {
              this.searchForm.administrativeLevel = this.searchForm.administrativeLevel.split(',')
            }
            if (this.searchForm.twoInstitutionalName !== '') {
              this.searchForm.twoInstitutionalName = this.searchForm.twoInstitutionalName.split(',')
            }
            if (this.searchForm.jobNature !== '') {
              this.searchForm.jobNature = this.searchForm.jobNature.split(',')
            }
            if (this.searchForm.identity !== '') {
              this.searchForm.identity = this.searchForm.identity.split(',')
            }
            this.searchOneInstitutional()
            this.searchIdentity()
            this.searchAdministrative()
            this.searchjobNature()
          }
        })
      },
      // 提示弹出自定义的方法 第一个参数content值是内容 第二个参数title是标题
      alertPrompt (content, title) {
        this.$alert(content, title, {
          confirmButtonText: '确定'
        })
      },
      // list循环请求数值 用于后续判断数值是否为空
      dataValidation (data) {
        // 调用异步循环组件的循环请求方法
        this.$refs.asynForTool.func('/peopleinformation/peopleassessdata/peopleAssessInformation/list', 'get', data, true)
      },
      // 考核人员信息导出到考核人员信息模块
     async assess (val) {
        this.loading = true
        this.state = 'list'
        this.dataListSelectionDeal = []
        this.dataListSelectionDealSearch = []
        this.time = ''
        this.$http({
          url: '/peopleinformation/checktime/checkTime/list',
          method: 'get',
          params: {
            'pageSize': 9999,
            'remarks': '人员'
          }
        }).then(({data}) => {
          if (data && data.success) {
            if (data.page.list[0] !== undefined) {
              if (val === 'add') {
                this.time = data.page.list[0].time.split('-')[0] + '-' + (Number(data.page.list[0].time.split('-')[1]) + 1)
                this.timeState = 'add'
              } else {
                this.time = data.page.list[0].time
                this.timeState = ''
              }
            } else {
              this.time = new Date().getFullYear() + '-' + 1
              this.timeState = 'add'
            }
            // 将多选拿到的值进行部分筛选 筛选出有用的值进行存储
            for (var index in this.dataListSelections) {
              this.dataListSelectionDeal.push({})
              this.dataListSelectionDealSearch.push({})
              this.dataListSelectionDeal[index] = this.lodash.pick(this.dataListSelections[index], 'photo', 'name', 'currentPosition', 'identity', 'remarks', 'workNumber', 'organizationLevel', 'special')
              this.$set(this.dataListSelectionDeal[index], 'unit', this.dataListSelections[index].oneInstitutional)
              this.$set(this.dataListSelectionDeal[index], 'userId', this.dataListSelections[index].id)
              this.$set(this.dataListSelectionDealSearch[index], 'userId', this.dataListSelections[index].id)
              this.$set(this.dataListSelectionDealSearch[index], 'ticketCount', this.time)
              this.$set(this.dataListSelectionDeal[index], 'ticket', this.dataListSelections[index].organizationLevel)
              this.$set(this.dataListSelectionDeal[index], 'ticketCount', this.time)
            }
            this.dataListSelectionDealAgain = []
            this.finishNumber = 0
            this.submitNumber = this.dataListSelectionDeal.length
            this.dataValidation(this.dataListSelectionDealSearch)
            this.importAssess('查找中，请勿刷新网页')
            this.loading = false
          }
        })
      },
      // 考核人员导出功能的提示弹窗，主要用于数据等待，防止数据传输过不来，这就需要弹窗友好提示
      importAssess (content) {
        this.loadings = this.$loading({
          lock: true,
          text: content,
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)',
          customClass: 'loadingStyle'
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageNo = 1
        this.refreshList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageNo = val
        this.refreshList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },
    // 排序
      sortChangeHandle (obj) {
        if (obj.order === 'ascending') {
          this.orderBy = obj.prop + ' asc'
        } else if (obj.order === 'descending') {
          this.orderBy = obj.prop + ' desc'
        } else {
          this.orderBy = ''
        }
        this.refreshList()
      },
      // 新增
      add () {
        this.$refs.peopleInformationForm.init('add', '')
      },
      // 修改
      edit (id) {
        id = id || this.dataListSelections.map(item => {
          return item.id
        })[0]
        this.$refs.peopleInformationForm.init('edit', id)
      },
      // 查看
      view (id) {
        this.$refs.peopleInformationForm.init('view', id)
      },
      // 删除
      del (id) {
        let ids = id || this.dataListSelections.map(item => {
          return item.id
        }).join(',')
        this.$confirm(`确定删除所选项吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.loading = true
          this.$http({
            url: '/peopleinformation/basicdata/peopleInformation/delete',
            method: 'delete',
            params: {'ids': ids}
          }).then(({data}) => {
            if (data && data.success) {
              this.$message.success(data.msg)
              this.refreshList()
            }
            this.loading = false
          })
        })
      },
      // 导入成功
      uploadSuccess (res, file) {
        if (res.success) {
          this.$message.success({dangerouslyUseHTMLString: true,
            message: res.msg})
        } else {
          this.$message.error(res.msg)
        }
      },
      // 下载模板
      downloadTpl () {
        this.$utils.download('/peopleinformation/basicdata/peopleInformation/import/template')
      },
      // 导出表格方法
      exportExcel () {
        this.loading = true
        this.tests = false
        // 等待dom节点更新触发的函数
        this.$nextTick(function () {
          this.$exportXLXS.exportDataXlsx(this.$refs['report-table'].$el, '人员信息')
          this.loading = false
          this.tests = true
        })
      },
      resetSearch () {
        this.$refs.searchForm.resetFields()
        this.refreshList()
      }
    }
  }
</script>
<style type="text/css">
  .loadingStyle {
    font-size: 32px;
  }
</style>
